<?php
/* [$WindsForce] (C)Hunzhiwange.COM Since 2014.07.08.
   广告位置模型($$)*/

!defined('Q_PATH') && exit;

class AdpositionModel extends CommonModel{

	static public function init__(){
		return array(
			'table_name'=>'adposition',
			'autofill'=>array(
				array('adposition_edituserid','userId','all','callback'),
				array('adposition_editusername','userName','all','callback'),
			),
			'check'=>array(
				'adposition_name'=>array(
					array('require',Q::L('广告位置名字不能为空','__COMMON_LANG__@Common')),
					array('max_length',35,Q::L('广告位置名字最大长度为35','__COMMON_LANG__@Common'))
				),
				'adposition_code'=>array(
					array('require',Q::L('广告位置代码不能为空','__COMMON_LANG__@Common')),
					array('number_underline_english',Q::L('广告位置代码只能是字母、数字和下划线','__COMMON_LANG__@Common')),
					array('max_length',25,Q::L('广告位置代码最大长度为25','__COMMON_LANG__@Common')),
					array('adpositionName',Q::L('广告位置代码已经存在','__COMMON_LANG__@Common'),'condition'=>'must','extend'=>'callback'),
				),
			),
		);
	}

	static function F(){
		$arrArgs=func_get_args();
		return ModelMeta::instance(__CLASS__)->findByArgs($arrArgs);
	}

	static function M(){
		return ModelMeta::instance(__CLASS__);
	}

	public function adpositionName(){
		return self::uniqueField_('adposition_code','adposition_id','id');
	}

	protected function beforeSave_(){
		$this->adposition_app=C::text($this->adposition_app);
		$this->adposition_name=C::text($this->adposition_name);
		$this->adposition_code=C::strip($this->adposition_code);
		$this->adposition_editusername=C::text($this->adposition_editusername);
	}

}
